<script language="javascript">
	function back(){
		document.location="<?php echo site_url(); ?>/master_user";
	}
</script>
<?php
echo form_open("/master_user/form_user/".$parameter, array("name"=>"form_user","id"=>"medic_form"));
if($parameter == FALSE){
	$username	= set_value("username");
	$mahasiswa	= set_value("mahasiswa");
	$role		= set_value("role");
	$status		= set_value("status");
} else {
	$username	= $value["USERNAME"];
	$mahasiswa	= $value["ID_MAHASISWA"];
	$role		= $value["ROLE"];
	$status		= $value["STATUS"];
}
?>
<p>
	<label>Username</label>
	<input type="text" name="username" value="<?php echo $username; ?>">
	<?php echo form_error("username"); ?>
</p>
<p>
	<label>Password</label>
	<input type="password" name="password" value="">
	<?php echo form_error("password"); ?>
</p>
<p>
	<label>Password Konfirmasi</label>
	<input type="password" name="c_password" value="">
	<?php echo form_error("c_password"); ?>
</p>
<p>
	<label>Status</label>
	<select name="status">
		<option value="">-- Pilih Status --</option>
		<option value="1" <?php echo ($status == 1) ? ("selected") : (""); ?>>Aktif</option>
		<option value="2" <?php echo ($status == 2) ? ("selected") : (""); ?>>Tidak Aktif</option>
	</select>
	<?php echo form_error("status"); ?>
</p>
<p>
	<label>Hak Akses</label>
	<select name="role" onChange="show(this)">
		<option value="">-- Pilih Hak Akses --</option>
		<option value="1" <?php echo ($role == 1) ? ("selected") : (""); ?>>Dosen</option>
		<option value="2" <?php echo ($role == 2) ? ("selected") : (""); ?>>Mahasiswa</option>
	</select>
	<?php echo form_error("role"); ?>
</p>
<p id="role" <?php echo ($role == 2) ? ("") : ("style=\"display:none;\""); ?>>
	<label>Pilih Mahasiswa</label>
	<select name="mahasiswa">
		<option value="">-- Pilih Mahasiswa --</option>
		<?php
		foreach($q_mahasiswa as $row){
		?>
		<option value="<?php echo $row["ID_MAHASISWA"]; ?>" <?php echo ($mahasiswa == $row["ID_MAHASISWA"]) ? ("selected") : (""); ?>><?php echo $row["NAMA"]; ?></option>
		<?php
		}
		?>
	</select>
	<?php echo form_error("mahasiswa"); ?>
</p>
<p>
	<input type="submit" class="btn btn-primary" id="submit" value="Simpan">
	<input type="reset" class="btn btn-primary" id="submit" value="Reset">
	<input type="button" class="btn btn-primary" id="submit" value="Kembali" onClick="back()">
</p>
<?php echo form_close(); ?>
<script language="javascript">
function show(operand){
	if(operand.options[operand.selectedIndex].value == "2"){
		document.getElementById("role").style.display="block";
	}else{
		document.getElementById("role").style.display="none";
	}
}
</script>